const app = getApp()
import req from '../../utils/Request.js';
import appReq from '../../utils/AppRequest.js';
Page({
  data: {
    keyId: '',
    list: null,
    phone: "",
    housePicture: ""
  },
  getSuccess: function (res) {
    req.postFormData('/index/consultPrice.do', { housesId: this.data.keyId,
      mobile: this.data.phone, openId: app.globalData.openId }).then(res => {
      if (res.code == 1) {
        wx.navigateTo({
          url: '../success/index'
        })
        wx.hideLoading();
      } else {
        app.showErrorMessage(res, '加载失败');
        wx.hideLoading();
        return;
      }
    }).catch(res => {
      wx.hideLoading();
      wx.showToast({
        title: '网络异常',
        icon: 'none'
      });
      console.log("err catch");
    });
  },

  onLoad: function (value) {
    this.setData({
      keyId: value.keyId,
      phone: value.phone,
    })
    this.getDetail()
  },

  getDetail: function () {
    req.get('/index/housesDetail.do', { housesId: this.data.keyId }).then(res => {
      if (res.code == 1) {
        this.setData({
          list: res.data,
        })
        this.setData({
          housePicture: res.data.housePicture.split(',')[0],
        })
        wx.hideLoading();
      } else {
        app.showErrorMessage(res, '加载失败');
        wx.hideLoading();
        return;
      }
    }).catch(res => {
      wx.hideLoading();
      wx.showToast({
        title: '网络异常',
        icon: 'none'
      });
      console.log("err catch");
    });
  },

})